-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement automatic test directory for r2r #16365
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before doing any chdir based on the r2r exectuable, you must check:
- If a test path was given manually, find the base relative to that
- If no path was given, but there is a "db" directory in cwd, don't cd at all
Otherwise it will be unusable in certain cases for r2ghidra for example.
@@ -94,6 +152,18 @@ int main(int argc, char **argv) { | |||
} | |||
} | |||
|
|||
if (r2r_dir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to fix all paths given as args because if they are relative, they will be broken after cd'ing, making them absolute will probably be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then we need to chdir multiple times and chdir-back to the original one after each path assuming the user can pass multiple test files from different working directories
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one run-path for all given paths is enough. But as it is right now, you will be unable to load the tests at all.
pls review again |
binr/r2r/r2r.c
Outdated
char *cwd = NULL; | ||
while (true) { | ||
cwd = r_sys_getdir (); | ||
if (r_file_is_root (cwd)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't check for root at all. If chdir fails for whatever reason you will still loop forever. Just do this instead:
char *last_cwd = NULL;
while (true) {
last_cwd = cwd;
cwd = r_sys_getdir();
if (last_cwd && !strcmp (last_cwd, cwd)) {
free (last_cwd);
free (cwd);
break;
}
free (last_cwd);
....
done |
The relative path issue is still not fixed, other than that lgtm. |
which relative path issue? passing a test in relative works fine |
Ah ok got it didnt tried with directories |
fixed:
|
Your checklist for this pull request
Detailed description
...
Test plan
...
Closing issues
...